import { getOptions } from '@/api/common'

const common = {
  state: {
    allBrand: [],
    allCategory: [],
    allMerchant: [],
    batchId: '',
    isReviseBtn:false
  },
  mutations: {
    SET_COMMON_OPTION: (state, data) => {
      state.allBrand = data.brandList
      state.allCategory = data.categoryList
      state.allMerchant = data.merchantList
    },
    setBatchId: (state, data) => {
      state.batchId = data;
    },
    setIsReviseBtn: (state, data) => {
      state.isReviseBtn = data;
    }
  },
  actions: {
    async GetOptions({ commit }) {
      try {
        const res = await getOptions()
        if (res.errorCode === 0) {
          commit('SET_COMMON_OPTION', res.data)
        }
      } catch (error) {
        throw new Error(error)
      }
    }
  }
}
export default common
